class Seiso::ImportMaster
  class Importers::DataCenterImporter < Importers::BaseImporter

    def initialize(api, rest_util, resolver)
      @log = Util::Logger.new "DataCenterImporter"

      self.api = api
      self.rest_util = rest_util
      self.mapper = Mappers::DataCenterMapper.new resolver
      self.repo_resource = api.dataCenters.get

      @log.info "Getting /dataCenters/search"
      @search_resource = repo_resource.search.get
    end

    def import(doc)
      @log.info "Importing data centers"
      import_items(doc['items'], {})
    end

    def to_search_params(doc_dc, context)
      { 'key' => doc_dc['key'] }
    end

    def find_resource(search_params)
      key = search_params['key']
      @log.info "Getting /dataCenters/search/findByKey?key=#{key}"
      @search_resource.findByKey(key: key).get
    end
  end
end
